import { request } from "@/utils/http"
// 引入接口类型
import {
  IHospitalListPrams,
  IHospitalListsLsResponse,
  IHospitalCityType,
  IHospitalShow,
  DepartmentList,
  reqGetHospitalRuleListResponse,
  IScheduleRuleParams,
  IHosScheduleList,
  Status,
} from "./model/hospitalListsType"

// 获取医院列表 接口函数
export const reqHospitalList = ({
  page,
  pageSize,
  hosname,
  hoscode,
  hostype,
  provinceCode,
  cityCode,
  districtCode,
  status,
}: IHospitalListPrams) => {
  return request.get<any, IHospitalListsLsResponse>(
    `/admin/hosp/hospital/${page}/${pageSize}`,
    {
      params: {
        page,
        pageSize,
        hosname,
        hoscode,
        hostype,
        provinceCode,
        cityCode,
        districtCode,
        status,
      },
    }
  )
}

// 获取省 接口函数
export const reqHospitalFromCity = (dictCode: string = "province") => {
  return request.get<any, IHospitalCityType>(
    `/admin/cmn/dict/findByDictCode/${dictCode}`
  )
}

// 获取市、区、状态等 接口函数
export const reqHospitalCities = (parentId: string) => {
  return request.get<any, IHospitalCityType>(
    `/admin/cmn/dict/findByParentId/${parentId}`
  )
}

// 获取 医院详情 接口函数
export const reqGetHospitalShow = (id: string) => {
  return request.get<any, IHospitalShow>(`/admin/hosp/hospital/show/${id}`)
}

// 获取 医院科室 接口函数
export const reqGetDepartmentList = (hoscode: string) => {
  return request.get<any, DepartmentList>(`/admin/hosp/department/${hoscode}`)
}

// 获取 医院排班日期 接口函数
export const reqGetHospitalRuleTags = ({
  page,
  pageSize,
  hoscode,
  depcode,
}: IScheduleRuleParams) => {
  return request.get<any, reqGetHospitalRuleListResponse>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${pageSize}/${hoscode}/${depcode}`
  )
}

// 获取 医院排班 接口函数
export const reqGetHosScheduleList = (
  hoscode: string,
  depcode: string,
  workDate: string
) => {
  return request.get<any, IHosScheduleList>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  )
}

// 获取 医院上线/下线 接口函数
export const reqUpdateHosStatus = (id: string, status: Status) => {
  return request.get<any, null>(
    `/admin/hosp/hospital/updateStatus/${id}/${status}`
  )
}
